Tack.Condition = new Class({
	args: {},
	type: null,

	negate: false,

	changeSceneReferences: function (oldName, newName) {},

	compile: function () {
		var values = {};
		for (var property in this.args)
			values[property] = this[property];

		return [this.type, this.negate, values];
	},

	evaluate: function (player, eventArgs) {
		return this._evaluate(player, eventArgs) != this.negate;
	},

	_evaluate: function (player, eventArgs) {
		return true;
	},

	remove: function () {
		this.actionBlock.conditions.remove(this);
	},

	setActionBlock: function (actionBlock) {
		this.actionBlock = actionBlock;
		this.scene = actionBlock.scene;
	}
});

Tack.Condition.decompile = function (arr) {
	var type = Tack.Condition[arr[0]];
	if (!type)
		throw 'Encountered unknown condition type.';

	var condition = new type();
	condition.negate = !!arr[1];
	for (var i in condition.args) {
		condition[i] = arr[2][i];
	}

	return condition;
};
